package com.zzq.result;

import com.fasterxml.jackson.annotation.JsonInclude;
import io.swagger.models.auth.In;
import lombok.Getter;
import lombok.Setter;
import lombok.ToString;


@JsonInclude(JsonInclude.Include.NON_NULL)
@ToString
public class SmileResult<T> {
    /**
     * 状态码
     */
    private Integer code;
    /**
     * 提示信息，如果有错误时，前端可以获取该字段进行提示
     */
    private String msg;
    /**
     * 查询到的结果数据，
     */
    private T value;

    @Getter
    @Setter
    private Integer currentPage;
    @Getter
    @Setter
    private Integer pageSize;
    @Getter
    @Setter
    private Long total;
    public SmileResult(Integer code, String msg) {
        this.code = code;
        this.msg = msg;
    }

    public SmileResult(Integer code, T value) {
        this.code = code;
        this.value = value;
    }

    public Integer getCode() {
        return code;
    }

    public void setCode(Integer code) {
        this.code = code;
    }

    public String getMsg() {
        return msg;
    }

    public void setMsg(String msg) {
        this.msg = msg;
    }

    public T getvalue() {
        return value;
    }

    public void setvalue(T value) {
        this.value = value;
    }


    public SmileResult(Integer code, String msg, T value) {
        this.code = code;
        this.msg = msg;
        this.value = value;
    }

    public  static SmileResult  sucess(String msg){
        return new SmileResult(200,msg);
    }
    public  static SmileResult  sucess(){
        return new SmileResult(200,"成功");
    }
    public  static SmileResult  sucess(Object data){
        return new SmileResult(200,"成功",data);
    }
    public  static SmileResult  sucess(String msg,Object data){
        return new SmileResult(200,msg,data);
    }
    public  static SmileResult  waring(String msg){
        return new SmileResult(300,msg);
    }
    public  static SmileResult  waring(String msg,Object data){
        return new SmileResult(300,msg,data);
    }
    public  static SmileResult  error(String msg){
        return new SmileResult(500,msg);
    }
}
